package 二叉树系列;

public class CountNodes {
    public int countNodes(TreeNode root) {
        return getNodes(root);
    }
    public int getNodes(TreeNode node){
        if(node==null) return 0;
        int leftNum = getNodes(node.left);
        int rightNUm = getNodes(node.right);
        int treeNum = leftNum + rightNUm + 1;
        return treeNum;
    }
}
